package com.trimps.wifi.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trimps.wifi.common.Constants;
import com.trimps.wifi.pojo.FlowData;
import com.trimps.wifi.service.MapTrackService;

@Controller
@RequestMapping(value = "map/")
public class MapTrackController extends BaseController {
    private static final Logger logger = Logger.getLogger(MapTrackController.class);

    @Autowired
    private MapTrackService mapTrackService;

    
    @RequestMapping(value = "mapTrack")
    public String showMapTrackPage() {
        return "map/mapTrack";
    }
    
    /**
     * 获取列表信息
     * @param 
     * @return
     */
    @RequestMapping(value = "getMacLocation", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> getMacLocation(
                    @RequestParam(value="deviceMac", required = false) String deviceMac,
                    @RequestParam(value="deviceNo", required = false) String deviceNo,
                    @RequestParam(value="startTime", required = false) String startTime,
                    @RequestParam(value="endTime", required = false) String endTime)  {
     // 返回用
        Map<String, Object> map = new HashMap<String, Object>();
        int totalCount;
        List<FlowData> lst = new ArrayList<FlowData>();
        
        totalCount = mapTrackService.getMacLocationCount(deviceMac, deviceNo, startTime, endTime);
        lst = mapTrackService.getMacLocation(deviceMac, deviceNo, startTime, endTime);
       
        map.put("listInfo", lst);
        map.put("totalCount", totalCount);
        return map;
    }
    
    
}
